package com.mzy.linear_struct.subject;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: codermzy
 * @Date: 2024/04/28/下午2:18
 * @Description:
 */
public class 寻找重复数287 {

    static class Solution {
        public int findDuplicate(int[] nums) {
            int[] ctx = new int[nums.length];
            for (int i = 0; i < ctx.length; i++) {
                ctx[nums[i]]++;
            }

            for (int i = 1; i < ctx.length; i++) {
                if (ctx[i] > 1) {
                    return i;
                }
            }

            return -1;
        }
    }

    public static void main(String[] args) {


    }
}
